<template>
	<view>
		<view class="bg" :style="{ '--bg-image': `url(${tgyLogin})` }" >
			<view class="display-a-jc">
				<image class="act" :src="logo"></image>
			</view>
			<view class="text-align_center">推广员登录</view>
			<view class="frame">
				<view class="font-size_36rpx margin-bottom_20rpx">登录</view>
				<view class="color_999999 font-size_24rpx">登录后体验更多精彩内容</view>
				<view class="display-a padding-bottom_20rpx p-bo margin-bottom_80rpx">
					<!-- <image class="img-2" src="/static/2.png"></image> -->
					<image class="img-2" src="../../static/组合 1878.png" mode=""></image>
					<input  type="number" maxlength="11" v-model="account" placeholder="请输入登录账号"
						placeholder-class="placeholder" />
				</view>
				<view class="display-a padding-bottom_20rpx p-bo">
					<!-- 	<image class="img-2" src="/static/3.png"></image> -->
					<image class="img-2" src="../../static/蒙版-1.png" mode=""></image>
					<input :password="showPassword" v-model="password" placeholder="请输入登录密码"
						placeholder-class="placeholder" />
				</view>
				<view class="login" @click="login()">登录</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				account: uni.getStorageSync("userName")?uni.getStorageSync("userName"):'',
				password: '',
                tgyLogin:this.$img.tgyLogin,
				logo: '',
				secondaryAgentName: '',
				showPassword:true,
				userInfo: uni.getStorageSync("userInfo"),
			}
		},

		onLoad() {
			// this.getLogo();
			// this.oemCode = uni.getStorageSync('oemCode');
		},

		onShow() {

		},

		methods: {

			//获取一级代理logo——暂不使用
			async getLogo() {
				const result = await this.$http.post({
					url: this.$api.getAddressConfiguration,
					data: {
						proxyAddress: window.location.origin
					},
					headers: {
						'Authorization': this.userInfo.token
					}
				});

				if (result.code == 2000) {
					this.logo = result.data.systemIcon;
					this.secondaryAgentName = result.data.secondaryAgentName;
				}
			},

			async login() {

				if (!this.account) {
					this.$sun.toast("请输入登录账号", 'none');
					return;
				}

				if (!this.password) {
					this.$sun.toast("请输入登录密码", 'none');
					return;
				}

				const result = await this.$http.post({
					url: this.$api.promoterLogin,
					data: {
						account: this.account,
						password: this.password,
						id:this.userInfo.id
					}
				});


				if (result.code == 0) {
					this.$sun.toast("登录成功");
					setTimeout(() => {
						uni.setStorageSync("loginInfo", result.data);
						uni.setStorageSync("userName", this.account);
						this.$sun.navTo('/pagesB/index/promotionCenter','none')
						
					}, 2000);
				} else {
					this.$sun.toast(result.message, 'none');
				}
			},

		}
	}
</script>

<style lang="scss">
	.margin-bottom_80rpx {
		margin-bottom: 80rpx;
	}

	.color_999999 {
		margin-bottom: 80rpx;
	}

	input {
		width: 360rpx;
	}

	.img-2 {
		width: 44rpx;
		height: 44rpx;
		margin-right: 20rpx;
		margin-left: 30rpx;
	}

	.login {
		font-size: 32rpx;
		color: #FFFFFF;
		width: 520rpx;
		padding: 20rpx;
		text-align: center;
		border-radius: 70rpx;
		background: linear-gradient(99deg, #8771FF 0%, #879CFF 100%);
		margin-top: 100rpx;
		margin-bottom: 80rpx;
	}

	.frame {
		width: 620rpx;
		padding: 80rpx 50rpx;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		margin-left: 64rpx;
	}

	.text-align_center {
		color: #FFFFFF;
		padding: 24rpx;
		font-weight: bold;
	}

	.act {
		width: 130rpx;
		height: 130rpx;
		border-radius: 100%;
	}

	.bg {
		background-image: (var(--bg-image));
		// background: url('~static/蒙版.png');
		width: 750rpx;
		height: 1624rpx;
		background-repeat: no-repeat;
		background-size: contain;
		padding-top: 84rpx;
	}

	page {
		background-color: #393CD7;
		border-top: 0 solid #FFFFFF;
	}
</style>